** Set directories 
cd "/win/l1werpfile2/Shared/Olivia/Rob/Covid_Unemployment_Paths"
local input "/l1-res/shared/micro/projects/unrestricted/CPS_2014_Database/Stata Databases"

** Read-in data
use "`input'/CPS_Match.dta", clear 

** Monthly date variable (used below)
capture drop ym
gen date=ym(year,month)
format date %tm

keep if year == 2020 & month >= 1 & month <= 7

** Peridnum (identifier needed for merge)
tostring(hhid), replace format(%015.0f)
tostring(hhidtwo), replace format(%05.0f)
tostring(lineno), replace format(%02.0f)
egen hhidtest = concat(hhid hhidtwo) 
egen peridnum = concat(hhidtest lineno)

** Keep ID + industry/occupation variables needed for merge
keep peridnum month ind occ

tempfile data
save `data'

** Merge & save with unbalanced dataset
merge 1:1 peridnum month using "Output/CPS_2020_unbalanced.dta", keep(3) nogen
save "Output/CPS_2020_unbalanced_v2.dta", replace

** Merge & save with balanced dataset
use `data'
merge 1:1 peridnum month using "Output/CPS_2020_balanced.dta", keep(3) nogen
save "Output/CPS_2020_balanced_v2.dta", replace
